/**
 * Jaxson ajax
 *
 * Copyright Remedy Interactive, licensed under Apache version 2 license:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0.html
 *
 * This notice must remain in all java source files.
 */

package org.jaxson.struts.logging;


import java.util.HashMap;
import java.util.Map;

/**
 * Log level for javascript logging.
 * 
 * @author Joe Maisel
 */
public enum LogLevel
{
	TRACE(1), DEBUG(2), INFO(3), WARN(4), ERROR(5);

	private int num;

	private LogLevel (int num)
	{
		this.num = num;
	}

	public int asNumber()
	{
		return this.num;
	}

	public static String asJavascript()
	{

		String result = "";

		for( LogLevel l : LogLevel.values() )
		{

			result += "\r\nLogger.LEVEL_" + l.name() + "=" + l.num + ";\r\n";
		}

		return result;
	}

	public static Map<Integer, String> asMap()
	{
		Map<Integer, String> result = new HashMap<Integer, String>();

		for( LogLevel l : LogLevel.values() )
		{
			result.put( l.num, l.name() );
		}

		return result;
	}
}
